<template>
  <cfg-form :ref="ref" v-bind="attrs" :data="data.values"></cfg-form>
</template>

<script>
import { typeClassName } from "@/pages/config/classNameMap";
export default {
  name: "pg-form",
  components: {},
  inject: ["anc"],
  data() {
    return {
      ref: "detailView",
      onlyRead: false,
      loading: false,
      
    };
  },
  props: {
    data: {
      default: () => {
        return {};
      },
    },
  },
  watch: {},
  computed: {
    attrs() {
      return {
        labelWidth: 100,
        labelPosition: "right",
        cols: 2,
        columns: [
        {
            key: "sf_code",
            title: "类别编码",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "sf_name",
            title: "类别名称",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
          {
            key: "category",
            title: "所属分类",
            minWidth: 100,
            align: "center",
            config: {
              type: "select",
              options: [
                { label: "设备", value: "设备" },
                { label: "仪表", value: "仪表" },
              ],
            },
          },
          {
            key: "brevity",
            title: "类别简码",
            minWidth: 100,
            align: "center",
            config: { type: "text" },
          },
         
          {
            key: "remark",
            title: "备注",
            minWidth: 100,
            align: "center",
            config: { type: "textarea" },
          },
        ],
        rules: {
          sf_code: [
            { required: true, message: "不能为空", trigger: "blur" },
          ],
          sf_name: [
            { required: true, message: "不能为空", trigger: "blur" },
          ],
         
          category: [
            { required: true, message: "请选择", trigger: "change" },
          ],
        },
        // onlyRead: this.onlyRead,
      };
    },
  },
  created() {},
  mounted() {
    this.$nextTick(() => {
      this.$set(this.anc.vms, this.ref, this);
      
    });
  },
  methods: {
    validate(fn) {
      return this.$refs[this.ref].$refs["form"].validate((valid) => {
        if (fn) {
          return fn(valid);
        } else {
          return valid;
        }
      });
    },
    resetFields() {
      this.$refs[this.ref].$refs["form"].resetFields();
    },
  },
};
</script>
<style scoped></style>
